home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 210 / DPCS0805.ISO / Assets / Interface / Install.dxr / 00001_Install Window.swf / scripts / __Packages / InstallStep.as
Encoding:
Text File  |  2005-05-17  |  9.1 KB  |  263 lines

  1. class InstallStep extends mx.core.UIObject
  2. {
  3.    var __stepRefs;
  4.    var __bottom;
  5.    var __btnListener;
  6.    var __scrollPane;
  7.    var __stepsClip;
  8.    var dispatchEvent;
  9.    static var symbolName = "InstallStep";
  10.    static var symbolOwner = InstallStep;
  11.    var className = "InstallStep";
  12.    static var version = "0.0.0.1";
  13.    static var __maxPageHeight = 300;
  14.    static var __pageBorder = 5;
  15.    static var __vSpacing = 5;
  16.    static var __hSpacing = 5;
  17.    var __nextDepth = 1;
  18.    function InstallStep()
  19.    {
  20.       super();
  21.       mx.events.EventDispatcher.initialize(this);
  22.    }
  23.    function init(Void)
  24.    {
  25.       super.init();
  26.       this.__stepRefs = new Array();
  27.       this.__bottom = 0;
  28.       this.__btnListener = new Object();
  29.       this.__btnListener.click = function(evtObj)
  30.       {
  31.          _level0.getURL(evtObj.target.target);
  32.       };
  33.    }
  34.    function size(Void)
  35.    {
  36.       super.size();
  37.    }
  38.    function get numSteps()
  39.    {
  40.       return this.__stepRefs.length;
  41.    }
  42.    function set clipHolder(scrollPane)
  43.    {
  44.       this.__scrollPane = scrollPane;
  45.    }
  46.    function doneSetting()
  47.    {
  48.       var adjustment = this.createEmptyMovieClip("bottomAdjust",this.__nextDepth);
  49.       with(adjustment)
  50.       {
  51.          beginFill("0xFFFFE5",0);
  52.          moveTo(0,0);
  53.          lineTo(0,20);
  54.          lineTo(10,20);
  55.          endFill();
  56.       }
  57.       adjustment._visible = true;
  58.       adjustment._x = 0;
  59.       adjustment._y = this.__bottom;
  60.       this.__bottom = adjustment._y + adjustment._height;
  61.       trace("__bottom: " + this.__bottom);
  62.       trace("adjustment: " + adjustment._y);
  63.       trace("adjustment: " + adjustment._height);
  64.       if(this.__scrollPane != undefined)
  65.       {
  66.          if(this.height > this.__scrollPane.height - 4)
  67.          {
  68.             this.__scrollPane.setSize(this.__scrollPane.width + 20,this.__scrollPane.height);
  69.             this.__scrollPane.move(this.__scrollPane._x - 10,this.__scrollPane._y);
  70.          }
  71.       }
  72.       if(this.numSteps == 1)
  73.       {
  74.          trace("THERE IS ONLY ONE STEP");
  75.          trace("setting text to: " + this.__stepRefs[0].text.slice("<img src=\'clip1\' hspace=\'8\' vspace=\'3\' width=\'32\' height=\'32\' />".length));
  76.          this.__stepRefs[0].text = this.__stepRefs[0].text.slice("<img src=\'clip1\' hspace=\'8\' vspace=\'3\' width=\'32\' height=\'32\' />".length);
  77.       }
  78.       trace("HEIGHT TEST");
  79.       trace(this.height);
  80.       trace(this.__scrollPane.height - 4);
  81.       if(this.height <= this.__scrollPane.height - 4)
  82.       {
  83.          _level0.stepsPane.move(-5,29);
  84.          _level0.stepsPane.setSize(_level0.stepsPane.width + 15,_level0.stepsPane.height);
  85.          trace(this.__stepRefs[0].width);
  86.          this.__stepRefs[0].setSize(this.__stepRefs[0].width + 15,this.__stepRefs[0].height);
  87.          trace(this.__stepRefs[0].width);
  88.          trace("sending " + Math.ceil(this.__bottom) + " as bottom of Flash movie to Director");
  89.          this.repositionCloseBtn(this.__bottom);
  90.          var integerBottom = Math.ceil(this.__bottom);
  91.          ┬º┬ºpush(this.getURL("lingo: resizeDialog " add integerBottom));
  92.       }
  93.    }
  94.    function repositionCloseBtn(bottom)
  95.    {
  96.       trace("reposition received: " + bottom);
  97.       _level0.closeBtn.move(_level0.closeBtn.x,bottom + 25);
  98.       _level0.footerBar._y = bottom + 15;
  99.       _level0.footerBar._visible = true;
  100.       _level0.gradients._visible = false;
  101.       this.__bottom = _level0.closeBtn.y + _level0.closeBtn.height + 11;
  102.    }
  103.    function get clipPosn()
  104.    {
  105.       return this.__stepsClip._x + ", " + this.__stepsClip._y;
  106.    }
  107.    function set title(title)
  108.    {
  109.       var _loc2_ = this.attachMovie("Label","dlgTitle",this.__nextDepth);
  110.       this.__nextDepth = this.__nextDepth + 1;
  111.       _loc2_.autoSize = "none";
  112.       _loc2_.setSize(260,22);
  113.       _loc2_.embedFonts = true;
  114.       _loc2_.setStyle("styleName","dialogTitleStyle");
  115.       _loc2_.text = title;
  116.       _loc2_.move(34,4);
  117.    }
  118.    function set step(stepData)
  119.    {
  120.       var _loc17_ = undefined;
  121.       var _loc9_ = this.__stepRefs.length + 1;
  122.       var _loc12_ = undefined;
  123.       if(_loc9_ >= 1 && _loc9_ < 25)
  124.       {
  125.          _loc12_ = "step" + _loc9_;
  126.       }
  127.       else
  128.       {
  129.          _loc12_ = "step25";
  130.       }
  131.       var _loc13_ = "step" + _loc9_;
  132.       var _loc3_ = this.attachMovie("TextArea",_loc13_,this.__nextDepth);
  133.       this.__nextDepth = this.__nextDepth + 1;
  134.       _loc3_.wordWrap = true;
  135.       _loc3_.editable = false;
  136.       _loc3_.label.selectable = false;
  137.       _loc3_.borderStyle = "none";
  138.       _loc3_.hScrollPolicy = _loc3_.vScrollPolicy = "off";
  139.       _loc3_.html = true;
  140.       _loc3_.embedFonts = true;
  141.       _loc3_.styleSheet = _global.stepStyles;
  142.       _loc3_.setStyle("styleName","scrollTextAreaStyle");
  143.       _loc3_.text = "<img src=\'" + _loc12_ + "\' hspace=\'8\' vspace=\'3\' width=\'32\' height=\'32\' /><stepbody>" + stepData.stepText + "</stepbody>";
  144.       _loc3_.move(0,this.__bottom + 6);
  145.       var _loc6_ = undefined;
  146.       _loc6_ = _loc3_.styleSheet._styles.stepbody.getTextExtent(this.removeHTMLTags(stepData.stepText),305);
  147.       trace("GETTEXTEXTENT2:");
  148.       trace("  " + _loc6_);
  149.       trace("  " + _loc6_.width);
  150.       trace("  " + _loc6_.height);
  151.       var _loc16_ = _level0.stepsPane.height;
  152.       var _loc10_ = _loc6_.ascent + _loc6_.descent;
  153.       trace("rowHeight: " + _loc10_);
  154.       var _loc5_ = _loc10_ + 4;
  155.       var _loc7_ = _loc6_.textFieldHeight;
  156.       var _loc8_ = 0;
  157.       while(_loc7_ > _loc5_)
  158.       {
  159.          _loc8_ = _loc8_ + 1;
  160.          _loc7_ -= _loc5_;
  161.       }
  162.       var _loc14_ = _loc8_ != 0 ? 6 + _loc10_ + _loc8_ * _loc5_ : 6 + _loc10_;
  163.       trace("AUTO TEXTFIELDHEIGHT: " + _loc6_.textFieldHeight);
  164.       trace("ADJUSTED TEXTFIELDHEIGHT: " + 1.15 * _loc6_.textFieldHeight);
  165.       trace("MANUAL TEXTFIELDHEIGHT: " + _loc14_);
  166.       _loc3_.setSize(_loc6_.textFieldWidth,1.15 * _loc6_.textFieldHeight + 4);
  167.       this.__stepRefs.push(_loc3_);
  168.       if(_loc3_.height < 45)
  169.       {
  170.          _loc3_.setSize(_loc3_.width,48.85);
  171.       }
  172.       this.__bottom = _loc3_._y + _loc3_.height + InstallStep.__vSpacing;
  173.       if(stepData.target != undefined)
  174.       {
  175.          var _loc15_ = "btn" + _loc9_;
  176.          var _loc4_ = this.attachMovie("Button",_loc15_,this.__nextDepth);
  177.          this.__nextDepth = this.__nextDepth + 1;
  178.          _loc4_.embedFonts = true;
  179.          _loc4_.styleSheet = _global.stepStyles;
  180.          _loc4_.setStyle("styleName","buttonStyle");
  181.          _loc4_.label = stepData.btnlabel.toUpperCase();
  182.          _loc4_.target = stepData.target;
  183.          _loc4_.addEventListener("click",this.__btnListener);
  184.          _loc6_ = _loc4_.styleSheet._styles.stepbtn.getTextExtent(this.removeHTMLTags(stepData.btnlabel));
  185.          _loc4_.setSize(_loc6_.textFieldWidth + 30,_loc4_.height);
  186.          _loc4_.move(_loc3_._x + _loc3_.width - _loc4_.width - 10,this.__bottom);
  187.          this.__bottom = _loc4_.top + _loc4_.height + 2 * InstallStep.__vSpacing;
  188.       }
  189.       trace("Step text height: " + _loc3_.height);
  190.       trace("");
  191.    }
  192.    function removeHTMLTags(htmlText)
  193.    {
  194.       var _loc6_ = function(txt, index)
  195.       {
  196.          return txt.indexOf("<",index);
  197.       };
  198.       var _loc8_ = function(txt, index)
  199.       {
  200.          return txt.indexOf(">",index);
  201.       };
  202.       var _loc2_ = new Array();
  203.       var _loc7_ = 0;
  204.       var _loc9_ = undefined;
  205.       var _loc10_ = undefined;
  206.       while(_loc7_ < htmlText.length)
  207.       {
  208.          _loc9_ = _loc6_(htmlText,_loc7_);
  209.          if(_loc9_ == -1)
  210.          {
  211.             break;
  212.          }
  213.          _loc10_ = _loc8_(htmlText,_loc9_);
  214.          var _loc3_ = _loc6_(htmlText,_loc10_);
  215.          while(_loc3_ == _loc10_ + 1)
  216.          {
  217.             _loc10_ = _loc8_(htmlText,_loc3_);
  218.             _loc3_ = _loc6_(htmlText,_loc10_);
  219.          }
  220.          _loc2_.push({start:_loc9_,end:_loc10_});
  221.          _loc7_ = _loc10_ + 1;
  222.       }
  223.       var _loc5_ = 0;
  224.       while(_loc5_ < _loc2_.length)
  225.       {
  226.          _loc9_ = _loc2_[_loc5_].start;
  227.          var _loc11_ = htmlText.charAt(_loc2_[_loc5_].start);
  228.          _loc10_ = _loc2_[_loc5_].end;
  229.          var _loc12_ = htmlText.charAt(_loc2_[_loc5_].end);
  230.          var _loc16_ = htmlText.substring(_loc9_ + 1,_loc10_);
  231.          _loc5_ = _loc5_ + 1;
  232.       }
  233.       if(_loc2_.length != 0)
  234.       {
  235.          var _loc18_ = "";
  236.          if(_loc2_[0].start > 0)
  237.          {
  238.             _loc18_ += htmlText.substring(0,_loc2_[0].start);
  239.          }
  240.          var _loc4_ = 0;
  241.          while(_loc4_ < _loc2_.length - 1)
  242.          {
  243.             var _loc13_ = _loc2_[_loc4_].end + 1;
  244.             var _loc15_ = _loc2_[_loc4_ + 1].start;
  245.             _loc18_ += htmlText.substring(_loc2_[_loc4_].end + 1,_loc2_[_loc4_ + 1].start);
  246.             _loc4_ = _loc4_ + 1;
  247.          }
  248.          if(_loc2_[_loc2_.length - 1].end < htmlText.length - 1)
  249.          {
  250.             _loc18_ += htmlText.substring(_loc2_[_loc2_.length - 1].end + 1);
  251.          }
  252.          return _loc18_;
  253.       }
  254.       return htmlText;
  255.    }
  256.    function sendMessage(p_msgtxt)
  257.    {
  258.       var _loc2_ = {target:this,type:"pageReady"};
  259.       _loc2_.msgtxt = p_msgtxt;
  260.       this.dispatchEvent(_loc2_);
  261.    }
  262. }
  263.